package org.hzero.order.app.service.impl;

import org.hzero.order.app.service.LineService;
import org.hzero.order.domain.entity.Line;
import org.hzero.order.domain.repository.LineRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author xiuiqng.Yang-Estelle-양수청
 * @date 2019/8/7 19:42
 */
@Service
public class LineServiceImpl implements LineService {

    @Autowired
    private LineRepository lineRepository;

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Line insertLine(Line line) {
        lineRepository.insert(line);
        return line;
    }


    @Transactional(rollbackFor = Exception.class)
    @Override
    public Line updateLine(Line line) {
        Line line1 = lineRepository.selectByPrimaryKey(line);
        if (line1!=null){
            lineRepository.updateByPrimaryKeySelective(line);
        }
        return line;
    }

    @Override
    public Line deleteLine(Line line) {
        Line line1 = lineRepository.selectByPrimaryKey(line);
        if (line1!=null){
            lineRepository.delete(line);
        }
        return line;
    }
}
